<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <!-- 引用在线arcgis api -->
    <link rel="stylesheet" href="https://js.arcgis.com/4.16/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.16/"></script>
    <style>
        html,
        body,
        #viewDiv {
            height: 100%;
            width: 100%;
            margin: 0;
            padding: 0;
        }
    </style>

    <script>
        require([
            "esri/Map",
            "esri/Basemap",
            "esri/views/MapView",
            "esri/views/SceneView",
            "esri/geometry/Extent",
            "esri/geometry/SpatialReference",
            "esri/geometry/Point",
            "esri/geometry/Polyline",
            "esri/geometry/Polygon",
            "esri/Graphic",
            "esri/widgets/Sketch",
            "esri/Color",
            "esri/layers/support/TileInfo",
            "esri/layers/WebTileLayer",
            "esri/views/layers/LayerView",
            "esri/layers/TileLayer",
            "esri/layers/MapImageLayer",
            "esri/layers/FeatureLayer",
            "esri/layers/GraphicsLayer",
            "esri/symbols/SimpleMarkerSymbol",
            "esri/symbols/SimpleFillSymbol",
            "esri/symbols/SimpleLineSymbol",
            "esri/tasks/support/BufferParameters",
            "esri/tasks/GeometryService",
            "esri/core/urlUtils",
            "esri/tasks/FindTask",
            "esri/tasks/support/FindParameters",
            "esri/tasks/QueryTask",
            "esri/tasks/support/Query",
            "esri/tasks/IdentifyTask",
            "esri/tasks/support/IdentifyParameters",
            "dojo/dom",
            "dojo/on",
            "dojo/domReady!"
        ], function(
            Map,
            Basemap,
            MapView,
            SceneView,
            Extent,
            SpatialReference,
            Point,
            Polyline,
            Polygon,
            Graphic,
            Sketch,
            Color,
            TileInfo,
            WebTileLayer,
            LayerView,
            TileLayer,
            MapImageLayer,
            FeatureLayer,
            GraphicsLayer,
            SimpleMarkerSymbol,
            SimpleFillSymbol,
            SimpleLineSymbol,
            BufferParameters,
            GeometryService,
            urlUtils,
            FindTask,
            FindParameters,
            QueryTask,
            Query,
            IdentifyTask,
            IdentifyParameters,
            dom,
            on) {
            //创建一个地图Map实例
            //使用天地图
            var layer = new MapImageLayer({
                url: "http://localhost:6080/arcgis/rest/services/Qingdao1/MapServer"
            });
            var map = new Map({ //属性：allLayers、ground、layers
                basemap: "topo",
                layers: [layer]
            });
            //创建一个MapView实例（用于2D查看）并引用该地图实例
            //为了使地图在DOM中对用户可见，必须创建一个MapView并至少引用两个对象：一个Map实例和一个DOM元素。分别在map和container属性中设置。
            var view = new MapView({
                container: "viewDiv",
                map: map,
                zoom: 4,
                center: [55, 65] // longitude, latitude
            });
            // QueryTask
            function Query1() {
                var queryTask = new QueryTask({
                    url: "http://localhost:6080/arcgis/rest/services/Qingdao1/MapServer"
                });
                var query = new Query();
                query.geometry = geometry;
                query.returnGeometry = true;
                query.outFields = ["*"];
                query.where = "POP &gt; 1000000";

                queryTask.execute(query).then(function(results) {
                    console.log(results.features);
                });
            };
            //FindTask
            function Find1() {
                var find = new FindTask({
                    url: "http://localhost:6080/arcgis/rest/services/Qingdao1/MapServer"
                });
                var params = new FindParameters({
                    layerIds: [0],
                    searchFields: ["areaname"]
                });
                find.execute(params).then(showResults).catch(rejectedPromise);
            };
            //ldentifyTask
            function ldentifyTask1() {
                var identify = new IdentifyTask({
                    url: "http://localhost:6080/arcgis/rest/services/Qingdao1/MapServer"
                });
                var Parameter = new IdentifyParameters();
                Parameter.returnGeometry = true;
                Parameter.tolerance = 3;
                Parameter.layerIds = [0, 1];
                Parameter.mapExtent = map.Extent;

                //源几何图形，就是用户点击处的esri.Geometry.Point
                Parameter.geometry = event.mapPoint;

                //只有LAYER_OPTION_ALL才能识别出指定的多图层
                params.layerOption = IdentifyParameters.LAYER_OPTION_ALL;
                identifytask.execute(params, function(results) {
                    Console.log(results);
                });
            };
            document.getElementsByClassName("")
                // document.getElementsByClassName("")
                // document.getElementsByClassName("")
        });
    </script>
</head>

<body>
    <div id="viewDiv">
        <button class="query" onclick="">QueryTask属性/空间查询</button>
        <button class="find">FindTask属性查询</button>
        <button class="identify">ldentifyTask空间查询</button>
    </div>
</body>

</html>